using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NiSis.Entities;
using NiSis.Data;
using NiSis.Class;

namespace NiSis
{
    public partial class Report : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                MeseAnnoPicker1.SelectCommandVisible = false;
                MeseAnnoPicker1.SelectAll = true;
            }
        }
        protected void LoadGrid(string cdMese)
        {
            VList<VReport> rpt=DataRepository.VReportProvider.Get(String.Format("Cd_storico_mensile_rete='{0}'",cdMese),"Dsc_Stato");
            grdReport.DataSource=rpt;
            grdReport.Visible = true;
            //grdReport.Visible=rpt.Count>0;
            CmdCvs.Visible = rpt.Count > 0;
            grdReport.DataBind();
        }

        protected void cmdRefreshGrid_Click(object sender, ImageClickEventArgs e)
        {
            LoadGrid(MeseAnnoPicker1.DateValue);
        }

        protected void CmdCvs_Click(object sender, EventArgs e)
        {
            ExportUtil.ConvertGridToCSV(grdReport,string.Format("c:\\report({0}).csv",DateTime.Now.ToString().Replace("/","-")));
        }
        protected void grdReport_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType==DataControlRowType.DataRow)
                e.Row.Cells[0].Text = Server.UrlDecode(e.Row.Cells[0].Text);
        }
    }

}
